package demo;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        //目标：简易计算器开发
        //1.键盘录入两个整数，运算符
        Scanner sc =new Scanner(System.in);
        System.out.println("请输入第一个整数：");
        double num1 = sc.nextDouble();

        System.out.println("请输入第二个整数：");
        double num2 = sc.nextDouble();

        System.out.println("请输入运算符(+, -, *, /):");
        String operater = sc.next();
        double result =calc(num1, num2, operater);
        System.out.println("计算结果" + result);
    }

    public static double calc(double num1, double num2, String operater) {
        double result = 0;
        switch (operater){
            case "+":
                result = num1 + num2;
                break;
            case "-":
                result =num1 - num2;
                break;
            case "*":
                result =num1 * num2;
                break;
            case "/":
                result = num1 / num2;
                break;
            default:
                System.out.println("请输入正确的计算符:>");
        }
        return result;
    }
}
